home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume13 / rpc3.9 / part15 < prev    next >
Encoding:
Internet Message Format  |  1988-02-27  |  41.8 KB

  1. Subject:  v13i092:  Sun RPC, release 3.9, Part15/15
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Stephen X. Nahm <sxn@Sun.COM>
  7. Posting-number: Volume 13, Issue 92
  8. Archive-name: rpc3.9/part15
  9.  
  10. #! /bin/sh
  11. # This is a shell archive. To extract, remove the header and type "sh filename"
  12. #
  13. cd doc
  14. echo x - nfs.rfc.ms
  15. sed -e 's/^X//' > nfs.rfc.ms <<'Funky_Stuff'
  16. X.\" @(#)nfs.rfc.ms    1.2 87/11/09 3.9 RPCSRC
  17. X.de BT
  18. X.if \\n%=1 .tl ''- % -''
  19. X..
  20. X.ND
  21. X.\" prevent excess underlining in nroff
  22. X.if n .fp 2 R
  23. X.OH 'Network File System: Version 2 Protocol Specification''Page %'
  24. X.EH 'Page %''Network File System: Version 2 Protocol Specification'
  25. X.if \\n%=1 .bp
  26. X.SH
  27. \&Network File System: Version 2 Protocol Specification
  28. X.IX NFS "" "" "" PAGE MAJOR
  29. X.IX "Network File System" "" "" "" PAGE MAJOR
  30. X.IX NFS "version-2 protocol specification"
  31. X.IX "Network File System" "version-2 protocol specification"
  32. X.LP
  33. X.NH 0
  34. \&Status of this Standard
  35. X.LP
  36. Note: This chapter specifies a protocol that Sun Microsystems, Inc.,
  37. and others are using.  It specifies it in standard ARPA RFC form.
  38. X.NH 1
  39. \&Introduction
  40. X.IX NFS introduction
  41. X.LP
  42. The Sun Network Filesystem (NFS) protocol provides transparent remote 
  43. access to shared filesystems over local area networks.  The NFS 
  44. protocol is designed to be machine, operating system, network architecture, 
  45. and transport protocol independent.  This independence is 
  46. achieved through the use of Remote Procedure Call (RPC) primitives 
  47. built on top of an eXternal Data Representation (XDR).  Implementations
  48. exist for a variety of machines, from personal computers to
  49. supercomputers.
  50. X.LP
  51. The supporting mount protocol allows the server to hand out remote
  52. access privileges to a restricted set of clients.  It performs the
  53. operating system-specific functions that allow, for example, to
  54. attach remote directory trees to some local file system.
  55. X.NH 2
  56. \&Remote Procedure Call
  57. X.IX "Remote Procedure Call"
  58. X.LP
  59. Sun's remote procedure call specification provides a procedure-
  60. oriented interface to remote services.  Each server supplies a
  61. program that is a set of procedures.  NFS is one such "program".
  62. The combination of host address, program number, and procedure
  63. number specifies one remote service procedure.  RPC does not depend
  64. on services provided by specific protocols, so it can be used with
  65. any underlying transport protocol.  See the
  66. \fIRemote Procedure Calls: Protocol Specification\fP
  67. chapter of this manual.
  68. X.NH 2
  69. \&External Data Representation
  70. X.IX "eXternal Data Representation"
  71. X.LP
  72. The eXternal Data Representation (XDR) standard provides a common
  73. way of representing a set of data types over a network.  The NFS
  74. Protocol Specification is written using the RPC data description
  75. language. For more information, see the 
  76. \fIeXternal Data Representation Standard: Protocol Specification\fP
  77. chapter of this manual.  Sun provides implementations of XDR and
  78. RPC,  but NFS does not require their use.  Any software that
  79. provides equivalent functionality can be used, and if the encoding
  80. is exactly the same it can interoperate with other implementations
  81. of NFS.
  82. X.NH 2
  83. \&Stateless Servers
  84. X.IX "stateless servers"
  85. X.IX servers stateless
  86. X.LP
  87. The NFS protocol is stateless.  That is, a server does not need to
  88. maintain any extra state information about any of its clients in
  89. order to function correctly.  Stateless servers have a distinct
  90. advantage over stateful servers in the event of a failure.  With
  91. stateless servers, a client need only retry a request until the
  92. server responds; it does not even need to know that the server has
  93. crashed, or the network temporarily went down.  The client of a
  94. stateful server, on the other hand, needs to either detect a server
  95. crash and rebuild the server's state when it comes back up, or
  96. cause client operations to fail.
  97. X.LP
  98. This may not sound like an important issue, but it affects the
  99. protocol in some unexpected ways.  We feel that it is worth a bit
  100. of extra complexity in the protocol to be able to write very simple
  101. servers that do not require fancy crash recovery.
  102. X.LP
  103. On the other hand, NFS deals with objects such as files and
  104. directories that inherently have state -- what good would a file be
  105. if it did not keep its contents intact?  The goal is to not
  106. introduce any extra state in the protocol itself.  Another way to
  107. simplify recovery is by making operations "idempotent" whenever
  108. possible (so that they can potentially be repeated).
  109. X.NH 1
  110. \&NFS Protocol Definition
  111. X.IX NFS "protocol definition"
  112. X.IX NFS protocol
  113. X.LP
  114. Servers have been known to change over time, and so can the
  115. protocol that they use. So RPC provides a version number with each
  116. RPC request. This RFC describes version two of the NFS protocol.
  117. Even in the second version, there are various obsolete procedures
  118. and parameters, which will be removed in later versions. An RFC
  119. for version three of the NFS protocol is currently under
  120. preparation.
  121. X.NH 2
  122. \&File System Model
  123. X.IX "file system model"
  124. X.LP
  125. NFS assumes a file system that is hierarchical, with directories as
  126. all but the bottom-level files.  Each entry in a directory (file,
  127. directory, device, etc.)  has a string name.  Different operating
  128. systems may have restrictions on the depth of the tree or the names
  129. used, as well as using different syntax to represent the "pathname",
  130. which is the concatenation of all the "components" (directory and
  131. file names) in the name.  A "file system" is a tree on a single
  132. server (usually a single disk or physical partition) with a specified
  133. "root".  Some operating systems provide a "mount" operation to make
  134. all file systems appear as a single tree, while others maintain a
  135. "forest" of file systems.  Files are unstructured streams of
  136. uninterpreted bytes.  Version 3 of NFS uses a slightly more general
  137. file system model.
  138. X.LP
  139. NFS looks up one component of a pathname at a time.  It may not be
  140. obvious why it does not just take the whole pathname, traipse down
  141. the directories, and return a file handle when it is done.  There are
  142. several good reasons not to do this.  First, pathnames need
  143. separators between the directory components, and different operating
  144. systems use different separators.  We could define a Network Standard
  145. Pathname Representation, but then every pathname would have to be
  146. parsed and converted at each end.  Other issues are discussed in
  147. \fINFS Implementation Issues\fP below.
  148. X.LP
  149. Although files and directories are similar objects in many ways,
  150. different procedures are used to read directories and files.  This
  151. provides a network standard format for representing directories.  The
  152. same argument as above could have been used to justify a procedure
  153. that returns only one directory entry per call.  The problem is
  154. efficiency.  Directories can contain many entries, and a remote call
  155. to return each would be just too slow.
  156. X.NH 2
  157. \&RPC Information
  158. X.IX "RPC information"
  159. X.IP \fIAuthentication\fP
  160. The   NFS  service uses 
  161. X.I AUTH_UNIX ,
  162. X.I AUTH_DES ,
  163. or 
  164. X.I AUTH_SHORT 
  165. style
  166. authentication, except in  the  NULL procedure where   
  167. X.I AUTH_NONE 
  168. is also allowed.
  169. X.IP "\fITransport Protocols\fP"
  170. NFS currently is supported on UDP/IP only.  
  171. X.IP "\fIPort Number\fP"
  172. The NFS protocol currently uses the UDP port number 2049.  This is
  173. not an officially assigned port, so  later versions of the protocol
  174. use the ``Portmapping'' facility of RPC.
  175. X.NH 2
  176. \&Sizes of XDR Structures
  177. X.IX "XDR structure sizes"
  178. X.LP
  179. These are the sizes, given in decimal bytes, of various XDR
  180. structures used in the protocol:
  181. X.DS
  182. /* \fIThe maximum number of bytes of data in a READ or WRITE request\fP  */
  183. const MAXDATA = 8192;
  184.  
  185. /* \fIThe maximum number of bytes in a pathname argument\fP */
  186. const MAXPATHLEN = 1024;
  187.  
  188. /* \fIThe maximum number of bytes in a file name argument\fP */
  189. const MAXNAMLEN = 255;
  190.  
  191. /* \fIThe size in bytes of the opaque "cookie" passed by READDIR\fP */
  192. const COOKIESIZE  = 4;
  193.  
  194. /* \fIThe size in bytes of the opaque file handle\fP */
  195. const FHSIZE = 32;
  196. X.DE
  197. X.NH 2
  198. \&Basic Data Types
  199. X.IX "NFS data types"
  200. X.IX NFS "basic data types"
  201. X.LP
  202. The following XDR  definitions are basic  structures and types used
  203. in other structures described further on.
  204. X.KS
  205. X.NH 3
  206. \&\fIstat\fP
  207. X.IX "NFS data types" stat "" \fIstat\fP
  208. X.DS
  209. enum stat {
  210.     NFS_OK = 0,
  211.     NFSERR_PERM=1,
  212.     NFSERR_NOENT=2,
  213.     NFSERR_IO=5,
  214.     NFSERR_NXIO=6,
  215.     NFSERR_ACCES=13,
  216.     NFSERR_EXIST=17,
  217.     NFSERR_NODEV=19,
  218.     NFSERR_NOTDIR=20,
  219.     NFSERR_ISDIR=21,
  220.     NFSERR_FBIG=27,
  221.     NFSERR_NOSPC=28,
  222.     NFSERR_ROFS=30,
  223.     NFSERR_NAMETOOLONG=63,
  224.     NFSERR_NOTEMPTY=66,
  225.     NFSERR_DQUOT=69,
  226.     NFSERR_STALE=70,
  227.     NFSERR_WFLUSH=99
  228. };
  229. X.DE
  230. X.KE
  231. X.LP
  232. The 
  233. X.I stat 
  234. type  is returned with every  procedure's  results.   A
  235. value of 
  236. X.I NFS_OK 
  237. indicates that the  call completed successfully and
  238. the  results are  valid.  The  other  values indicate  some kind of
  239. error  occurred on the  server  side  during the servicing   of the
  240. procedure.  The error values are derived from UNIX error numbers.
  241. X.IP \fBNFSERR_PERM\fP:
  242. Not owner.  The caller does not have correct ownership
  243. to perform the requested operation.
  244. X.IP \fBNFSERR_NOENT\fP:
  245. No such file or directory.    The file or directory
  246. specified does not exist.
  247. X.IP \fBNFSERR_IO\fP:
  248. Some sort of hard  error occurred when the operation was
  249. in progress.  This could be a disk error, for example.
  250. X.IP \fBNFSERR_NXIO\fP:
  251. No such device or address.
  252. X.IP \fBNFSERR_ACCES\fP:
  253. Permission  denied.  The  caller does  not  have the
  254. correct permission to perform the requested operation.
  255. X.IP \fBNFSERR_EXIST\fP:
  256. File exists.  The file specified already exists.
  257. X.IP \fBNFSERR_NODEV\fP:
  258. No such device.
  259. X.IP \fBNFSERR_NOTDIR\fP:
  260. Not   a  directory.    The  caller  specified   a
  261. non-directory in a directory operation.
  262. X.IP \fBNFSERR_ISDIR\fP:
  263. Is a directory.  The caller specified  a directory in
  264. a non- directory operation.
  265. X.IP \fBNFSERR_FBIG\fP:
  266. File too large.   The  operation caused a file to grow
  267. beyond the server's limit.
  268. X.IP \fBNFSERR_NOSPC\fP:
  269. No space left on  device.   The operation caused the
  270. server's filesystem to reach its limit.
  271. X.IP \fBNFSERR_ROFS\fP:
  272. Read-only filesystem.  Write attempted on a read-only filesystem.
  273. X.IP \fBNFSERR_NAMETOOLONG\fP:
  274. File name   too   long.  The file  name  in  an operation was too long.
  275. X.IP \fBNFSERR_NOTEMPTY\fP:
  276. Directory   not empty.  Attempted  to   remove  a
  277. directory that was not empty.
  278. X.IP \fBNFSERR_DQUOT\fP:
  279. Disk quota exceeded.  The client's disk  quota on the
  280. server has been exceeded.
  281. X.IP \fBNFSERR_STALE\fP:
  282. The  "fhandle" given in   the arguments was invalid.
  283. That is, the file referred to by that file handle no longer exists,
  284. or access to it has been revoked.
  285. X.IP \fBNFSERR_WFLUSH\fP:
  286. The server's  write cache  used  in the
  287. X.I WRITECACHE 
  288. call got flushed to disk.
  289. X.LP
  290. X.KS
  291. X.NH 3
  292. \&\fIftype\fP
  293. X.IX "NFS data types" ftype "" \fIftype\fP
  294. X.DS
  295. enum ftype {
  296.     NFNON = 0,
  297.     NFREG = 1,
  298.     NFDIR = 2,
  299.     NFBLK = 3,
  300.     NFCHR = 4,
  301.     NFLNK = 5
  302. };
  303. X.DE
  304. X.KE
  305. The enumeration
  306. X.I ftype 
  307. gives the type of a file.  The type 
  308. X.I NFNON 
  309. indicates a non-file,
  310. X.I NFREG 
  311. is a regular file, 
  312. X.I NFDIR 
  313. is a directory,
  314. X.I NFBLK 
  315. is a block-special device, 
  316. X.I NFCHR 
  317. is a character-special device, and
  318. X.I NFLNK 
  319. is a symbolic link.
  320. X.KS
  321. X.NH 3
  322. \&\fIfhandle\fP
  323. X.IX "NFS data types" fhandle "" \fIfhandle\fP
  324. X.DS
  325. typedef opaque fhandle[FHSIZE];
  326. X.DE
  327. X.KE
  328. The
  329. X.I fhandle 
  330. is the file handle passed between the server and the client.  
  331. All file operations are done using file handles to refer to a file or 
  332. directory.  The file handle can contain whatever information the server
  333. needs to distinguish an individual file.
  334. X.KS
  335. X.NH 3
  336. \&\fItimeval\fP
  337. X.IX "NFS data types" timeval "" \fItimeval\fP
  338. X.DS
  339. struct timeval {
  340.     unsigned int seconds;
  341.     unsigned int useconds;
  342. };
  343. X.DE
  344. X.KE
  345. The 
  346. X.I timeval
  347. structure is the number of seconds and microseconds 
  348. since midnight January 1, 1970, Greenwich Mean Time.  It is used to 
  349. pass time and date information.
  350. X.KS
  351. X.NH 3
  352. \&\fIfattr\fP
  353. X.IX "NFS data types" fattr "" \fIfattr\fP
  354. X.DS
  355. struct fattr {
  356.     ftype        type;
  357.     unsigned int mode;
  358.     unsigned int nlink;
  359.     unsigned int uid;
  360.     unsigned int gid;
  361.     unsigned int size;
  362.     unsigned int blocksize;
  363.     unsigned int rdev;
  364.     unsigned int blocks;
  365.     unsigned int fsid;
  366.     unsigned int fileid;
  367.     timeval      atime;
  368.     timeval      mtime;
  369.     timeval      ctime;
  370. };
  371. X.DE
  372. X.KE
  373. The
  374. X.I fattr 
  375. structure contains the attributes of a file; "type" is the type of
  376. the file; "nlink" is the number of hard links to the file (the number
  377. of different names for the same file); "uid" is the user
  378. identification number of the owner of the file; "gid" is the group
  379. identification number of the group of the file; "size" is the size in
  380. bytes of the file; "blocksize" is the size in bytes of a block of the
  381. file; "rdev" is the device number of the file if it is type
  382. X.I NFCHR 
  383. or
  384. X.I NFBLK ;
  385. "blocks" is the number of blocks the file takes up on disk; "fsid" is
  386. the file system identifier for the filesystem containing the file;
  387. "fileid" is a number that uniquely identifies the file within its
  388. filesystem; "atime" is the time when the file was last accessed for
  389. either read or write; "mtime" is the time when the file data was last
  390. modified (written); and "ctime" is the time when the status of the
  391. file was last changed.  Writing to the file also changes "ctime" if
  392. the size of the file changes.
  393. X.LP
  394. "mode" is the access mode encoded as a set of bits.  Notice that the
  395. file type is specified both in the mode bits and in the file type.
  396. This is really a bug in the protocol and will be fixed in future
  397. versions.  The descriptions given below specify the bit positions
  398. using octal numbers.
  399. X.TS
  400. box tab (&) ;
  401. cfI cfI
  402. lfL l .
  403. Bit&Description
  404. _
  405. 0040000&This is a directory; "type" field should be NFDIR.
  406. 0020000&This is a character special file; "type" field should be NFCHR. 
  407. 0060000&This is a block special file; "type" field should be NFBLK. 
  408. 0100000&This is a regular file; "type" field should be NFREG.
  409. 0120000&This is a symbolic link file;  "type" field should be NFLNK. 
  410. 0140000&This is a named socket; "type" field should be NFNON.
  411. 0004000&Set user id on execution.
  412. 0002000&Set group id on execution.
  413. 0001000&Save swapped text even after use.
  414. 0000400&Read permission for owner.
  415. 0000200&Write permission for owner.
  416. 0000100&Execute and search permission for owner.
  417. 0000040&Read permission for group.
  418. 0000020&Write permission for group.
  419. 0000010&Execute and search permission for group.
  420. 0000004&Read permission for others.
  421. 0000002&Write permission for others.
  422. 0000001&Execute and search permission for others.
  423. X.TE
  424. X.KS
  425. Notes:
  426. X.IP 
  427. The bits are  the same as the mode   bits returned  by  the
  428. X.I stat (2)
  429. system call in the UNIX system.  The file  type is  specified  both in
  430. the mode  bits  and in  the file type.   This   is fixed  in future
  431. versions.
  432. X.IP
  433. The "rdev" field in the attributes structure is an operating system
  434. specific device specifier.  It  will be  removed and generalized in
  435. the next revision of the protocol.
  436. X.KE
  437. X.LP
  438. X.KS
  439. X.NH 3
  440. \&\fIsattr\fP
  441. X.IX "NFS data types" sattr "" \fIsattr\fP
  442. X.DS
  443. struct sattr {
  444.     unsigned int mode;
  445.     unsigned int uid;
  446.     unsigned int gid;
  447.     unsigned int size;
  448.     timeval      atime;
  449.     timeval      mtime;
  450. };
  451. X.DE
  452. X.KE
  453. The 
  454. X.I sattr
  455. structure contains the file attributes which can be set
  456. from the client.  The fields are the same as for  
  457. X.I fattr 
  458. above.  A "size" of zero  means the file should be  truncated.
  459. A value of -1 indicates a field that should be ignored.
  460. X.LP
  461. X.KS
  462. X.NH 3
  463. \&\fIfilename\fP
  464. X.IX "NFS data types" filename "" \fIfilename\fP
  465. X.DS
  466. typedef string filename<MAXNAMLEN>;
  467. X.DE
  468. X.KE
  469. The type
  470. X.I filename 
  471. is used for  passing file names  or  pathname components.
  472. X.LP
  473. X.KS
  474. X.NH 3
  475. \&\fIpath\fP
  476. X.IX "NFS data types" path "" \fIpath\fP
  477. X.DS
  478. typedef string path<MAXPATHLEN>;
  479. X.DE
  480. X.KE
  481. The type
  482. X.I path 
  483. is a pathname.  The server considers it as a string
  484. with no internal structure,  but to the client  it is the name of a
  485. node in a filesystem tree.
  486. X.LP
  487. X.KS
  488. X.NH 3
  489. \&\fIattrstat\fP
  490. X.IX "NFS data types" attrstat "" \fIattrstat\fP
  491. X.DS
  492. union attrstat switch (stat status) {
  493.     case NFS_OK:
  494.         fattr attributes;
  495.     default:
  496.         void;
  497. };
  498. X.DE
  499. X.KE
  500. The 
  501. X.I attrstat 
  502. structure is a common procedure result.  It contains
  503. a  "status" and,  if  the call   succeeded,   it also contains  the
  504. attributes of the file on which the operation was done.
  505. X.LP
  506. X.KS
  507. X.NH 3
  508. \&\fIdiropargs\fP
  509. X.IX "NFS data types" diropargs "" \fIdiropargs\fP
  510. X.DS
  511. struct diropargs {
  512.     fhandle  dir;
  513.     filename name;
  514. };
  515. X.DE
  516. X.KE
  517. The  
  518. X.I diropargs 
  519. structure is used  in  directory  operations.  The
  520. "fhandle" "dir" is the directory in  which to find the file "name".
  521. A directory operation is one in which the directory is affected.
  522. X.LP
  523. X.KS
  524. X.NH 3
  525. \&\fIdiropres\fP
  526. X.IX "NFS data types" diropres "" \fIdiropres\fP
  527. X.DS
  528. union diropres switch (stat status) {
  529.     case NFS_OK:
  530.         struct {
  531.             fhandle file;
  532.             fattr   attributes;
  533.         } diropok;
  534.     default:
  535.         void;
  536. };
  537. X.DE
  538. X.KE
  539. The results of a directory operation  are returned  in a 
  540. X.I diropres 
  541. structure.  If the call succeeded, a new file handle "file" and the
  542. "attributes" associated with that file are  returned along with the
  543. "status".
  544. X.NH 2
  545. \&Server Procedures
  546. X.IX "NFS server procedures" "" "" "" PAGE MAJOR
  547. X.LP
  548. The  protocol definition  is given as   a  set  of  procedures with
  549. arguments  and results defined using the   RPC  language.   A brief
  550. description of the function of each procedure should provide enough
  551. information to allow implementation.
  552. X.LP
  553. All of  the procedures  in   the NFS  protocol  are assumed  to  be
  554. synchronous.   When a procedure  returns to the  client, the client
  555. can assume that the operation has completed and any data associated
  556. with the request is  now on stable storage.  For  example, a client
  557. X.I WRITE 
  558. request   may  cause  the   server  to  update  data  blocks,
  559. filesystem information blocks (such as indirect  blocks),  and file
  560. attribute  information (size  and  modify  times).  When  the 
  561. X.I WRITE 
  562. returns to the client, it can assume  that the write  is safe, even
  563. in case of  a server  crash, and  it can discard the  data written.
  564. This is a very important part  of the statelessness  of the server.
  565. If the server waited to flush data from remote requests, the client
  566. would have to  save those requests so that  it could resend them in
  567. case of a server crash.
  568. X.ie t .DS
  569. X.el .DS L
  570.  
  571. X.ft I
  572. /*
  573. * Remote file service routines
  574. */
  575. X.ft CW
  576. program NFS_PROGRAM {
  577.     version NFS_VERSION {
  578.         void        NFSPROC_NULL(void)              = 0;
  579.         attrstat    NFSPROC_GETATTR(fhandle)        = 1;
  580.         attrstat    NFSPROC_SETATTR(sattrargs)      = 2;
  581.         void        NFSPROC_ROOT(void)              = 3;
  582.         diropres    NFSPROC_LOOKUP(diropargs)        = 4;
  583.         readlinkres NFSPROC_READLINK(fhandle)       = 5;
  584.         readres     NFSPROC_READ(readargs)          = 6;
  585.         void        NFSPROC_WRITECACHE(void)        = 7;
  586.         attrstat    NFSPROC_WRITE(writeargs)        = 8;
  587.         diropres    NFSPROC_CREATE(createargs)      = 9;
  588.         stat        NFSPROC_REMOVE(diropargs)       = 10;
  589.         stat        NFSPROC_RENAME(renameargs)      = 11;
  590.         stat        NFSPROC_LINK(linkargs)          = 12;
  591.         stat        NFSPROC_SYMLINK(symlinkargs)    = 13;
  592.         diropres    NFSPROC_MKDIR(createargs)        = 14;
  593.         stat        NFSPROC_RMDIR(diropargs)        = 15;
  594.         readdirres  NFSPROC_READDIR(readdirargs)    = 16;
  595.         statfsres   NFSPROC_STATFS(fhandle)         = 17;
  596.     } = 2;
  597. } = 100003;
  598. X.DE
  599. X.KS
  600. X.NH 3
  601. \&Do Nothing
  602. X.IX "NFS server procedures" NFSPROC_NULL "" \fINFSPROC_NULL\fP
  603. X.DS
  604. void 
  605. NFSPROC_NULL(void) = 0;
  606. X.DE
  607. X.KE
  608. This procedure does no work.   It is made available  in  all RPC
  609. services to allow server response testing and timing.
  610. X.KS
  611. X.NH 3
  612. \&Get File Attributes
  613. X.IX "NFS server procedures" NFSPROC_GETATTR "" \fINFSPROC_GETATTR\fP
  614. X.DS
  615. attrstat 
  616. NFSPROC_GETATTR (fhandle) = 1;
  617. X.DE
  618. X.KE
  619. If the reply  status is 
  620. X.I NFS_OK ,
  621. then  the reply attributes contains
  622. the attributes for the file given by the input fhandle.
  623. X.KS
  624. X.NH 3
  625. \&Set File Attributes
  626. X.IX "NFS server procedures" NFSPROC_SETATTR "" \fINFSPROC_SETATTR\fP
  627. X.DS
  628. struct sattrargs {
  629.     fhandle file;
  630.     sattr attributes;
  631.     };
  632.  
  633. attrstat
  634. NFSPROC_SETATTR (sattrargs) = 2;
  635. X.DE
  636. X.KE
  637. The  "attributes" argument  contains fields which are either  -1 or
  638. are  the  new value for  the  attributes of  "file".   If the reply
  639. status is 
  640. X.I NFS_OK ,
  641. then the  reply attributes have the attributes of
  642. the file after the "SETATTR" operation has completed.
  643. X.LP
  644. Note: The use of -1 to indicate an unused field in "attributes" is
  645. changed in the next version of the protocol.
  646. X.KS
  647. X.NH 3
  648. \&Get Filesystem Root
  649. X.DS
  650. void 
  651. NFSPROC_ROOT(void) = 3;
  652. X.DE
  653. X.KE
  654. Obsolete.  This procedure  is no longer used   because  finding the
  655. root file handle of a filesystem requires moving  pathnames between
  656. client  and server.  To  do  this right we would  have  to define a
  657. network  stan- dard  representation of   pathnames.   Instead,  the
  658. function  of  looking up  the   root  file handle  is  done  by the
  659. X.I MNTPROC_MNT 
  660. procedure.    (See the
  661. \fIMount Protocol Definition\fP
  662. below for details).
  663. X.KS
  664. X.NH 3
  665. \&Look Up File Name
  666. X.IX "NFS server procedures" NFSPROC_LOOKUP "" \fINFSPROC_LOOKUP\fP
  667. X.DS
  668. diropres
  669. NFSPROC_LOOKUP(diropargs) = 4;
  670. X.DE
  671. X.KE
  672. If  the reply "status"  is 
  673. X.I NFS_OK ,
  674. then the reply  "file" and reply
  675. "attributes" are the file handle and attributes for the file "name"
  676. in the directory given by "dir" in the argument.
  677. X.KS
  678. X.NH 3
  679. \&Read From Symbolic Link
  680. X.IX "NFS server procedures" NFSPROC_READLINK "" \fINFSPROC_READLINK\fP
  681. X.DS
  682. union readlinkres switch (stat status) {
  683.     case NFS_OK:
  684.         path data;
  685.     default:
  686.         void;
  687. };
  688.  
  689. readlinkres
  690. NFSPROC_READLINK(fhandle) = 5;
  691. X.DE
  692. X.KE
  693. If "status" has the value 
  694. X.I NFS_OK ,
  695. then the reply "data" is the data in 
  696. the symbolic link given by the file referred to by the fhandle argument.
  697. X.LP
  698. Note:  since   NFS always  parses pathnames    on the  client, the
  699. pathname in  a symbolic  link may  mean something  different (or be
  700. meaningless) on a different client or on the server if  a different
  701. pathname syntax is used.
  702. X.KS
  703. X.NH 3
  704. \&Read From File
  705. X.DS
  706. struct readargs {
  707.     fhandle file;
  708.     unsigned offset;
  709.     unsigned count;
  710.     unsigned totalcount;
  711. };
  712.  
  713. union readres switch (stat status) {
  714.     case NFS_OK:
  715.         fattr attributes;
  716.         nfsdata data;
  717.     default:
  718.         void;
  719. };
  720.  
  721. readres
  722. NFSPROC_READ(readargs) = 6;
  723. X.DE
  724. X.KE
  725. Returns  up  to  "count" bytes of   "data" from  the file  given by
  726. "file", starting at "offset" bytes from  the beginning of the file.
  727. The first byte of the file is  at offset zero.  The file attributes
  728. after the read takes place are returned in "attributes".
  729. X.LP
  730. Note: The  argument "totalcount" is  unused, and is removed in the
  731. next protocol revision.
  732. X.KS
  733. X.NH 3
  734. \&Write to Cache
  735. X.IX "NFS server procedures" NFSPROC_WRITECACHE "" \fINFSPROC_WRITECACHE\fP
  736. X.DS
  737. void
  738. NFSPROC_WRITECACHE(void) = 7;
  739. X.DE
  740. X.KE
  741. To be used in the next protocol revision.
  742. X.KS
  743. X.NH 3
  744. \&Write to File
  745. X.IX "NFS server procedures" NFSPROC_WRITE "" \fINFSPROC_WRITE\fP
  746. X.DS
  747. struct writeargs {
  748.     fhandle file;          
  749.     unsigned beginoffset;  
  750.     unsigned offset;       
  751.     unsigned totalcount;   
  752.     nfsdata data;
  753. };
  754.  
  755. attrstat    
  756. NFSPROC_WRITE(writeargs) = 8;
  757. X.DE
  758. X.KE
  759. Writes   "data" beginning  "offset"  bytes  from the  beginning  of
  760. "file".  The first byte  of  the file is at  offset  zero.  If  the
  761. reply "status" is NFS_OK, then  the reply "attributes" contains the
  762. attributes  of the file after the  write has  completed.  The write
  763. operation is atomic.  Data from this  call to 
  764. X.I WRITE 
  765. will not be mixed with data from another client's calls.
  766. X.LP
  767. Note: The arguments "beginoffset" and "totalcount" are ignored and
  768. are removed in the next protocol revision.
  769. X.KS
  770. X.NH 3
  771. \&Create File
  772. X.IX "NFS server procedures" NFSPROC_CREATE "" \fINFSPROC_CREATE\fP
  773. X.DS
  774. struct createargs {
  775.     diropargs where;
  776.     sattr attributes;
  777. };
  778.  
  779. diropres
  780. NFSPROC_CREATE(createargs) = 9;
  781. X.DE
  782. X.KE
  783. The file "name" is created  in the directory given  by "dir".   The
  784. initial  attributes of the  new file  are given by "attributes".  A
  785. reply "status"  of NFS_OK indicates that the  file was created, and
  786. reply "file"   and   reply "attributes"  are    its file handle and
  787. attributes.   Any  other reply  "status"  means that  the operation
  788. failed and no file was created.
  789. X.LP
  790. Note: This  routine should pass  an exclusive create flag, meaning
  791. "create the file only if it is not already there".
  792. X.KS
  793. X.NH 3
  794. \&Remove File
  795. X.IX "NFS server procedures" NFSPROC_REMOVE "" \fINFSPROC_REMOVE\fP
  796. X.DS
  797. stat
  798. NFSPROC_REMOVE(diropargs) = 10;
  799. X.DE
  800. X.KE
  801. The file "name" is  removed from the directory  given by "dir".   A
  802. reply of NFS_OK means the directory entry was removed.
  803. X.LP
  804. Note: possibly non-idempotent operation.
  805. X.KS
  806. X.NH 3
  807. \&Rename File
  808. X.IX "NFS server procedures" NFSPROC_RENAME "" \fINFSPROC_RENAME\fP
  809. X.DS
  810. struct renameargs {
  811.     diropargs from;    
  812.     diropargs to;
  813. };
  814.  
  815. stat
  816. NFSPROC_RENAME(renameargs) = 11;
  817. X.DE
  818. X.KE
  819. The existing file "from.name" in  the directory given by "from.dir"
  820. is renamed to "to.name" in the directory given by "to.dir".  If the
  821. reply  is 
  822. X.I NFS_OK ,
  823. the file was  renamed.  The  
  824. RENAME  
  825. operation is
  826. atomic on the server; it cannot be interrupted in the middle.
  827. X.LP
  828. Note: possibly non-idempotent operation.
  829. X.KS
  830. X.NH 3
  831. \&Create Link to File
  832. X.IX "NFS server procedures" NFSPROC_LINK "" \fINFSPROC_LINK\fP
  833. X.DS
  834. struct linkargs {
  835.     fhandle from;
  836.     diropargs to;
  837. };
  838.  
  839. stat
  840. NFSPROC_LINK(linkargs) = 12;
  841. X.DE
  842. X.KE
  843. Creates the  file "to.name"  in the directory  given   by "to.dir",
  844. which is a hard link to the existing file given  by "from".  If the
  845. return value is 
  846. X.I NFS_OK ,
  847. a link was created.  Any other return value
  848. indicates an error, and the link was not created.
  849. X.LP
  850. A hard link should have the property that changes  to either of the
  851. linked files are reflected in both files.  When a hard link is made
  852. to a  file, the attributes  for  the file should  have  a value for
  853. "nlink" that is one greater than the value before the link.
  854. X.LP
  855. Note: possibly non-idempotent operation.
  856. X.KS
  857. X.NH 3
  858. \&Create Symbolic Link
  859. X.IX "NFS server procedures" NFSPROC_SYMLINK "" \fINFSPROC_SYMLINK\fP
  860. X.DS
  861. struct symlinkargs {
  862.     diropargs from;
  863.     path to;
  864.     sattr attributes;
  865. };
  866.  
  867. stat
  868. NFSPROC_SYMLINK(symlinkargs) = 13;
  869. X.DE
  870. X.KE
  871. Creates the  file "from.name" with  ftype  
  872. X.I NFLNK 
  873. in  the  directory
  874. given by "from.dir".   The new file contains  the pathname "to" and
  875. has initial attributes given by "attributes".  If  the return value
  876. is 
  877. X.I NFS_OK ,
  878. a link was created.  Any other return value indicates an
  879. error, and the link was not created.
  880. X.LP
  881. A symbolic  link is  a pointer to another file.   The name given in
  882. "to" is  not interpreted by  the server, only stored in  the  newly
  883. created file.  When the client references a file that is a symbolic
  884. link, the contents of the symbolic  link are normally transparently
  885. reinterpreted  as a pathname  to substitute.   A 
  886. X.I READLINK 
  887. operation returns the data to the client for interpretation.
  888. X.LP
  889. Note:  On UNIX servers the attributes are never used, since
  890. symbolic links always have mode 0777.
  891. X.KS
  892. X.NH 3
  893. \&Create Directory
  894. X.IX "NFS server procedures" NFSPROC_MKDIR "" \fINFSPROC_MKDIR\fP
  895. X.DS
  896. diropres
  897. NFSPROC_MKDIR (createargs) = 14;
  898. X.DE
  899. X.KE
  900. The new directory "where.name" is created in the directory given by
  901. "where.dir".  The initial attributes of the new directory are given
  902. by "attributes".  A reply "status" of NFS_OK indicates that the new
  903. directory was created, and reply "file" and  reply "attributes" are
  904. its file  handle and attributes.  Any  other  reply "status"  means
  905. that the operation failed and no directory was created.
  906. X.LP
  907. Note: possibly non-idempotent operation.
  908. X.KS
  909. X.NH 3
  910. \&Remove Directory
  911. X.IX "NFS server procedures" NFSPROC_RMDIR "" \fINFSPROC_RMDIR\fP
  912. X.DS
  913. stat
  914. NFSPROC_RMDIR(diropargs) = 15;
  915. X.DE
  916. X.KE
  917. The existing empty directory "name" in the directory given by "dir"
  918. is removed.  If the reply is 
  919. X.I NFS_OK ,
  920. the directory was removed.
  921. X.LP
  922. Note: possibly non-idempotent operation.
  923. X.KS
  924. X.NH 3
  925. \&Read From Directory
  926. X.IX "NFS server procedures" NFSPROC_READDIR "" \fINFSPROC_READDIR\fP
  927. X.DS
  928. struct readdirargs {
  929.     fhandle dir;            
  930.     nfscookie cookie;
  931.     unsigned count;         
  932. };
  933.  
  934. struct entry {
  935.     unsigned fileid;
  936.     filename name;
  937.     nfscookie cookie;
  938.     entry *nextentry;
  939. };
  940.  
  941. union readdirres switch (stat status) {
  942.     case NFS_OK:
  943.         struct {
  944.             entry *entries;
  945.             bool eof;
  946.         } readdirok;
  947.     default:
  948.         void;
  949. };
  950.  
  951. readdirres
  952. NFSPROC_READDIR (readdirargs) = 16;
  953. X.DE
  954. X.KE
  955. Returns a variable number of  directory entries,  with a total size
  956. of up to "count" bytes, from the directory given  by "dir".  If the
  957. returned  value of "status"  is 
  958. X.I NFS_OK ,
  959. then  it  is followed  by a
  960. variable  number  of "entry"s.    Each "entry" contains  a "fileid"
  961. which consists of a  unique number  to identify the  file within  a
  962. filesystem,  the  "name" of the  file, and a "cookie" which   is an
  963. opaque pointer to the next entry in  the  directory.  The cookie is
  964. used  in the next  
  965. X.I READDIR 
  966. call to get more  entries  starting at a
  967. given point in  the directory.  The  special cookie zero (all  bits
  968. zero) can be used to get the entries starting  at the  beginning of
  969. the directory.  The "fileid" field should be the same number as the
  970. "fileid" in the the  attributes of the  file.  (See the
  971. \fIBasic Data Types\fP
  972. section.) The "eof" flag  has a value of 
  973. X.I TRUE 
  974. if there are no more entries in the directory.
  975. X.KS
  976. X.NH 3
  977. \&Get Filesystem Attributes
  978. X.IX "NFS server procedures" NFSPROC_STATFS "" \fINFSPROC_STATFS\fP
  979. X.DS
  980. union statfsres (stat status) {
  981.     case NFS_OK:
  982.         struct {
  983.             unsigned tsize; 
  984.             unsigned bsize; 
  985.             unsigned blocks;
  986.             unsigned bfree; 
  987.             unsigned bavail;
  988.         } info;
  989.     default:
  990.         void;
  991. };
  992.  
  993. statfsres
  994. NFSPROC_STATFS(fhandle) = 17;
  995. X.DE
  996. X.KE
  997. If the  reply "status"  is 
  998. X.I NFS_OK ,
  999. then the  reply "info" gives the
  1000. attributes for the filesystem that contains file referred to by the
  1001. input fhandle.  The attribute fields contain the following values:
  1002. X.IP tsize:   
  1003. The optimum transfer size of the server in bytes.  This is
  1004. the number  of bytes the server  would like to have in the
  1005. data part of READ and WRITE requests.
  1006. X.IP bsize:   
  1007. The block size in bytes of the filesystem.
  1008. X.IP blocks:  
  1009. The total number of "bsize" blocks on the filesystem.
  1010. X.IP bfree:   
  1011. The number of free "bsize" blocks on the filesystem.
  1012. X.IP bavail:  
  1013. The number of  "bsize" blocks  available to non-privileged users.
  1014. X.LP
  1015. Note: This call does not  work well if a  filesystem has  variable
  1016. size blocks.
  1017. X.NH 1
  1018. \&NFS Implementation Issues
  1019. X.IX "NFS implementation"
  1020. X.LP
  1021. The NFS protocol is designed to be operating system independent, but
  1022. since this version was designed in a UNIX environment, many
  1023. operations have semantics similar to the operations of the UNIX file
  1024. system.  This section discusses some of the implementation-specific
  1025. semantic issues.
  1026. X.NH 2
  1027. \&Server/Client Relationship
  1028. X.IX NFS "server/client relationship"
  1029. X.LP
  1030. The NFS protocol is designed to allow servers to be as simple and
  1031. general as possible.  Sometimes the simplicity of the server can be a
  1032. problem, if the client wants to implement complicated filesystem
  1033. semantics.
  1034. X.LP
  1035. For example, some operating systems allow removal of open files.  A
  1036. process can open a file and, while it is open, remove it from the
  1037. directory.  The file can be read and written as long as the process
  1038. keeps it open, even though the file has no name in the filesystem.
  1039. It is impossible for a stateless server to implement these semantics.
  1040. The client can do some tricks such as renaming the file on remove,
  1041. and only removing it on close.  We believe that the server provides
  1042. enough functionality to implement most file system semantics on the
  1043. client.
  1044. X.LP
  1045. Every NFS client can also potentially be a server, and remote and
  1046. local mounted filesystems can be freely intermixed.  This leads to
  1047. some interesting problems when a client travels down the directory
  1048. tree of a remote filesystem and reaches the mount point on the server
  1049. for another remote filesystem.  Allowing the server to follow the
  1050. second remote mount would require loop detection, server lookup, and
  1051. user revalidation.  Instead, we decided not to let clients cross a
  1052. server's mount point.  When a client does a LOOKUP on a directory on
  1053. which the server has mounted a filesystem, the client sees the
  1054. underlying directory instead of the mounted directory.  A client can
  1055. do remote mounts that match the server's mount points to maintain the
  1056. server's view.
  1057. X.LP
  1058. X.NH 2
  1059. \&Pathname Interpretation
  1060. X.IX NFS "pathname interpretation"
  1061. X.LP
  1062. There are a few complications to the rule that pathnames are always
  1063. parsed on the client.  For example, symbolic links could have
  1064. different interpretations on different clients.  Another common
  1065. problem for non-UNIX implementations is the special interpretation of
  1066. the pathname ".."  to mean the parent of a given directory.  The next
  1067. revision of the protocol uses an explicit flag to indicate the parent
  1068. instead.
  1069. X.NH 2
  1070. \&Permission Issues
  1071. X.IX NFS "permission issues"
  1072. X.LP
  1073. The NFS protocol, strictly speaking, does not define the permission
  1074. checking used  by servers.  However,  it is  expected that a server
  1075. will do normal operating system permission checking using 
  1076. X.I AUTH_UNIX 
  1077. style authentication as the basis of its protection mechanism.  The
  1078. server gets the client's effective "uid", effective "gid", and groups
  1079. on each call and uses them to check permission.  There are various
  1080. problems with this method that can been resolved in interesting ways.
  1081. X.LP
  1082. Using "uid" and "gid" implies that the client and server share the
  1083. same "uid" list.  Every server and client pair must have the same
  1084. mapping from user to "uid" and from group to "gid".  Since every
  1085. client can also be a server, this tends to imply that the whole
  1086. network shares the same "uid/gid" space.
  1087. X.I AUTH_DES 
  1088. (and the  next
  1089. revision of the NFS protocol) uses string names instead of numbers,
  1090. but there are still complex problems to be solved.
  1091. X.LP
  1092. Another problem arises due to the usually stateful open operation.
  1093. Most operating systems check permission at open time, and then check
  1094. that the file is open on each read and write request.  With stateless
  1095. servers, the server has no idea that the file is open and must do
  1096. permission checking on each read and write call.  On a local
  1097. filesystem, a user can open a file and then change the permissions so
  1098. that no one is allowed to touch it, but will still be able to write
  1099. to the file because it is open.  On a remote filesystem, by contrast,
  1100. the write would fail.  To get around this problem, the server's
  1101. permission checking algorithm should allow the owner of a file to
  1102. access it regardless of the permission setting.
  1103. X.LP
  1104. A similar problem has to do with paging in from a file over the
  1105. network.  The operating system usually checks for execute permission
  1106. before opening a file for demand paging, and then reads blocks from
  1107. the open file.  The file may not have read permission, but after it
  1108. is opened it doesn't matter.  An NFS server can not tell the
  1109. difference between a normal file read and a demand page-in read.  To
  1110. make this work, the server allows reading of files if the "uid" given
  1111. in the call has execute or read permission on the file.
  1112. X.LP
  1113. In most operating systems, a particular user (on the user ID zero)
  1114. has access to all files no matter what permission and ownership they
  1115. have.  This "super-user" permission may not be allowed on the server,
  1116. since anyone who can become super-user on their workstation could
  1117. gain access to all remote files.  The UNIX server by default maps
  1118. user id 0 to -2 before doing its access checking.  This works except
  1119. for NFS root filesystems, where super-user access cannot be avoided.
  1120. X.NH 2
  1121. \&Setting RPC Parameters
  1122. X.IX NFS "setting RPC parameters"
  1123. X.LP
  1124. Various file system parameters and options should be set at mount
  1125. time.  The mount protocol is described in the appendix below.  For
  1126. example, "Soft" mounts as well as "Hard" mounts are usually both
  1127. provided.  Soft mounted file systems return errors when RPC
  1128. operations fail (after a given number of optional retransmissions),
  1129. while hard mounted file systems continue to retransmit forever.
  1130. Clients and servers may need to keep caches of recent operations to
  1131. help avoid problems with non-idempotent operations.
  1132. X.NH 1
  1133. \&Mount Protocol Definition
  1134. X.IX "mount protocol" "" "" "" PAGE MAJOR
  1135. X.sp 1
  1136. X.NH 2
  1137. \&Introduction
  1138. X.IX "mount protocol" introduction
  1139. X.LP
  1140. The mount protocol is separate from, but related to, the NFS
  1141. protocol.  It provides operating system specific services to get the
  1142. NFS off the ground -- looking up server path names, validating user
  1143. identity, and checking access permissions.  Clients use the mount
  1144. protocol to get the first file handle, which allows them entry into a
  1145. remote filesystem.
  1146. X.LP
  1147. The mount protocol is kept separate from the NFS protocol to make it
  1148. easy to plug in new access checking and validation methods without
  1149. changing the NFS server protocol.
  1150. X.LP
  1151. Notice that the protocol definition implies stateful servers because
  1152. the server maintains a list of client's mount requests.  The mount
  1153. list information is not critical for the correct functioning of
  1154. either the client or the server.  It is intended for advisory use
  1155. only, for example, to warn possible clients when a server is going
  1156. down.
  1157. X.LP
  1158. Version one of the mount protocol is used with version two of the NFS
  1159. protocol.  The only connecting point is the
  1160. X.I fhandle 
  1161. structure, which is the same for both protocols.
  1162. X.NH 2
  1163. \&RPC Information
  1164. X.IX "mount protocol"  "RPC information"
  1165. X.IP \fIAuthentication\fP
  1166. The mount service uses 
  1167. X.I AUTH_UNIX 
  1168. and 
  1169. X.I AUTH_DES 
  1170. style authentication only.
  1171. X.IP "\fITransport Protocols\fP"
  1172. The mount service is currently supported on UDP/IP only.
  1173. X.IP "\fIPort Number\fP"
  1174. Consult the server's    portmapper, described  in   the 
  1175. \fIRemote Procedure Calls: Protocol Specification\fP\,
  1176. to  find  the  port number on which the mount service is registered.
  1177. X.NH 2
  1178. \&Sizes of XDR Structures
  1179. X.IX "mount protocol" "XDR structure sizes"
  1180. X.LP
  1181. These  are  the sizes,   given  in  decimal   bytes, of various XDR
  1182. structures used in the protocol:
  1183. X.DS
  1184. /* \fIThe maximum number of bytes in a pathname argument\fP */
  1185. const MNTPATHLEN = 1024;
  1186.  
  1187. /* \fIThe maximum number of bytes in a name argument\fP */
  1188. const MNTNAMLEN = 255;
  1189.  
  1190. /* \fIThe size in bytes of the opaque file handle\fP */
  1191. const FHSIZE = 32;
  1192. X.DE
  1193. X.NH 2
  1194. \&Basic Data Types
  1195. X.IX "mount protocol" "basic data types"
  1196. X.IX "mount data types"
  1197. X.LP
  1198. This section presents the data  types used by  the  mount protocol.
  1199. In many cases they are similar to the types used in NFS.
  1200. X.KS
  1201. X.NH 3
  1202. \&\fIfhandle\fP
  1203. X.IX "mount data types" fhandle "" \fIfhandle\fP
  1204. X.DS
  1205. typedef opaque fhandle[FHSIZE];
  1206. X.DE
  1207. X.KE
  1208. The type 
  1209. X.I fhandle 
  1210. is the file handle that the server passes to the
  1211. client.  All file operations are done  using file handles  to refer
  1212. to a  file  or directory.   The  file handle  can  contain whatever
  1213. information the server needs to distinguish an individual file.
  1214. X.LP
  1215. This  is the  same as the "fhandle" XDR definition in version 2 of
  1216. the NFS protocol;  see 
  1217. \fIBasic Data Types\fP
  1218. in the definition of the NFS protocol, above.
  1219. X.KS
  1220. X.NH 3
  1221. \&\fIfhstatus\fP
  1222. X.IX "mount data types" fhstatus "" \fIfhstatus\fP
  1223. X.DS
  1224. union fhstatus switch (unsigned status) {
  1225.     case 0:
  1226.         fhandle directory;
  1227.     default:
  1228.         void;
  1229. };
  1230. X.DE
  1231. X.KE
  1232. The type 
  1233. X.I fhstatus 
  1234. is a union.  If a "status" of zero is returned,
  1235. the  call completed   successfully, and  a  file handle   for   the
  1236. "directory"  follows.  A  non-zero  status indicates  some  sort of
  1237. error.  In this case the status is a UNIX error number.
  1238. X.KS
  1239. X.NH 3
  1240. \&\fIdirpath\fP
  1241. X.IX "mount data types" dirpath "" \fIdirpath\fP
  1242. X.DS
  1243. typedef string dirpath<MNTPATHLEN>;
  1244. X.DE
  1245. X.KE
  1246. The type 
  1247. X.I dirpath 
  1248. is a server pathname of a directory.
  1249. X.KS
  1250. X.NH 3
  1251. \&\fIname\fP
  1252. X.IX "mount data types" name "" \fIname\fP
  1253. X.DS
  1254. typedef string name<MNTNAMLEN>;
  1255. X.DE
  1256. X.KE
  1257. The type 
  1258. X.I name 
  1259. is an arbitrary string used for various names.
  1260. X.NH 2
  1261. \&Server Procedures
  1262. X.IX "mount server procedures"
  1263. X.LP
  1264. The following sections define the RPC procedures  supplied by a
  1265. mount server.
  1266. X.ie t .DS
  1267. X.el .DS L
  1268. X.ft I
  1269. /*
  1270. * Protocol description for the mount program
  1271. */
  1272. X.ft CW
  1273.  
  1274. program MOUNTPROG {
  1275. X.ft I
  1276. /*
  1277. * Version 1 of the mount protocol used with
  1278. * version 2 of the NFS protocol.
  1279. */
  1280. X.ft CW
  1281.     version MOUNTVERS {
  1282.         void        MOUNTPROC_NULL(void)    = 0;
  1283.         fhstatus    MOUNTPROC_MNT(dirpath)  = 1;
  1284.         mountlist   MOUNTPROC_DUMP(void)    = 2;
  1285.         void        MOUNTPROC_UMNT(dirpath) = 3;
  1286.         void        MOUNTPROC_UMNTALL(void) = 4;
  1287.         exportlist  MOUNTPROC_EXPORT(void)  = 5;
  1288.     } = 1;
  1289. } = 100005;
  1290. X.DE
  1291. X.KS
  1292. X.NH 3
  1293. \&Do Nothing
  1294. X.IX "mount server procedures" MNTPROC_NULL "" \fIMNTPROC_NULL\fP
  1295. X.DS
  1296. void 
  1297. MNTPROC_NULL(void) = 0;
  1298. X.DE
  1299. X.KE
  1300. This  procedure does no work.  It   is  made  available in all  RPC
  1301. services to allow server response testing and timing.
  1302. X.KS
  1303. X.NH 3
  1304. \&Add Mount Entry
  1305. X.IX "mount server procedures" MNTPROC_MNT "" \fIMNTPROC_MNT\fP
  1306. X.DS
  1307. fhstatus
  1308. MNTPROC_MNT(dirpath) = 1;
  1309. X.DE
  1310. X.KE
  1311. If the reply "status" is 0, then the reply "directory" contains the
  1312. file handle for the directory "dirname".  This file handle may be
  1313. used in the NFS protocol.  This procedure also adds a new entry to
  1314. the mount list for this client mounting "dirname".
  1315. X.KS
  1316. X.NH 3
  1317. \&Return Mount Entries
  1318. X.IX "mount server procedures" MNTPROC_DUMP "" \fIMNTPROC_DUMP\fP
  1319. X.DS
  1320. struct *mountlist {
  1321.     name      hostname;
  1322.     dirpath   directory;
  1323.     mountlist nextentry;
  1324. };
  1325.  
  1326. mountlist
  1327. MNTPROC_DUMP(void) = 2;
  1328. X.DE
  1329. X.KE
  1330. Returns  the list of  remote mounted filesystems.   The "mountlist"
  1331. contains one entry for each "hostname" and "directory" pair.
  1332. X.KS
  1333. X.NH 3
  1334. \&Remove Mount Entry
  1335. X.DS
  1336. void
  1337. MNTPROC_UMNT(dirpath) = 3;
  1338. X.DE
  1339. X.KE
  1340. Removes the mount list entry for the input "dirpath".
  1341. X.KS
  1342. X.NH 3
  1343. \&Remove All Mount Entries
  1344. X.IX "mount server procedures" MNTPROC_UMNTALL "" \fIMNTPROC_UMNTALL\fP
  1345. X.DS
  1346. void
  1347. MNTPROC_UMNTALL(void) = 4;
  1348. X.DE
  1349. X.KE
  1350. Removes all of the mount list entries for this client.
  1351. X.KS
  1352. X.NH 3
  1353. \&Return Export List
  1354. X.IX "mount server procedures" MNTPROC_EXPORT "" \fIMNTPROC_EXPORT\fP
  1355. X.DS
  1356. struct *groups {
  1357.     name grname;
  1358.     groups grnext;
  1359. };
  1360.  
  1361. struct *exportlist {
  1362.     dirpath filesys;
  1363.     groups groups;
  1364.     exportlist next;
  1365. };
  1366.  
  1367. exportlist
  1368. MNTPROC_EXPORT(void) = 5;
  1369. X.DE
  1370. X.KE
  1371. Returns a variable number of export list entries.  Each entry
  1372. contains a filesystem name and a list of groups that are allowed to
  1373. import it.  The filesystem name is in "filesys", and the group name
  1374. is in the list "groups".
  1375. X.LP
  1376. Note:  The exportlist should contain
  1377. more information about the status of the filesystem, such as a
  1378. read-only flag.
  1379. Funky_Stuff
  1380. len=`wc -c < nfs.rfc.ms`
  1381. if [ $len !=    41718 ] ; then
  1382.   echo error: nfs.rfc.ms was $len bytes long, should have been    41718
  1383. fi
  1384. cd ..
  1385. echo done with directory doc
  1386. exit
  1387.